using UnityEngine;

public class Player : MonoBehaviour
{
    [Header("移动速度")]
    public float speed;
    Vector3 movement;

    void Update()
    {
        //移动
        movement = new Vector3(Input.GetAxisRaw("Horizontal") * Time.deltaTime * speed, Input.GetAxisRaw("Vertical") * Time.deltaTime * speed, transform.position.z);
        transform.Translate(movement);

        //翻面
        if (movement.x > 0)
        {
            transform.GetChild(0).localScale = new Vector3(1, 1, 1);
        }
        if (movement.x < 0)
        {
            transform.GetChild(0).localScale = new Vector3(-1, 1, 1);
        }
    }
}
